import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class UrlLaunch extends StatefulWidget {
  final String title;

  UrlLaunch({Key key, this.title}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return UrlLaunchState();
  }
}

class UrlLaunchState extends State<UrlLaunch> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text(this.widget.title),
      ),
      body: Column(
        children: <Widget>[
          RaisedButton(
            onPressed: () {
              _sendDate();
            },
            child: Text('打电话（正机测试）'),
          ),
        ],
      ),
    );
  }

  void _sendDate() async {
    const url = 'tel:18048568002';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
}
